package com.group01.community.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.group01.community.entity.ZyOwnerRoomRecord;
import com.group01.community.entity.vo.ZyOwnerRoomVO;
import com.group01.community.entity.vo.ZyOwnerVO;
import com.group01.community.service.ZyOwnerRoomRecordService;
import com.group01.community.utils.ResponseResult;
import com.group01.community.utils.UUIDUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 房屋绑定记录表  前端控制器
 * </p>
 *
 * @author xuxu
 * @since 2022-07-04
 */
@RestController
@RequestMapping("/zyOwnerRoomRecord")
public class ZyOwnerRoomRecordController {

    @Autowired
    private ZyOwnerRoomRecordService zyOwnerRoomRecordService;

    @GetMapping("ownerRoomRecordList")
    public ResponseResult<List<ZyOwnerRoomRecord>> getZyOwnerRoomRecordByOwnerRoomId(Long ownerRoomId){
        List<ZyOwnerRoomRecord> list = zyOwnerRoomRecordService.getOwnerRoomRecordListByOwnerRoomId(ownerRoomId);
        return ResponseResult.ok(list);
    }


    /**
     *
     * @param zyOwnerRoomVO
     */
    @PostMapping("add")
    public ResponseResult<String> addOwnerRoomRecord(@RequestBody ZyOwnerRoomVO zyOwnerRoomVO){

        ZyOwnerRoomRecord zyOwnerRoomRecord = new ZyOwnerRoomRecord(UUIDUtils.getId(),zyOwnerRoomVO.getOwnerRoomId(),zyOwnerRoomVO.getCommunityId(),zyOwnerRoomVO.getBuildingId()
                                                                        ,zyOwnerRoomVO.getUnitId(),zyOwnerRoomVO.getRoomId(),zyOwnerRoomVO.getOwnerId(),zyOwnerRoomVO.getOwnerType(),
                                                                            zyOwnerRoomVO.getRoomStatus(),zyOwnerRoomVO.getRemark(),"",zyOwnerRoomVO.getOwnerId(),"admin",
                                                                                zyOwnerRoomVO.getCreateTime(),"",LocalDateTime.now(),"");

        zyOwnerRoomRecordService.save(zyOwnerRoomRecord);
        return ResponseResult.ok("ok");
    }

    /**
     *
     * @param zyOwnerVO
     */
    @PostMapping("addownerroom")
    public ResponseResult<String> addOwnerRecord(@RequestBody ZyOwnerVO zyOwnerVO){

        ZyOwnerRoomRecord zyOwnerRoomRecord = new ZyOwnerRoomRecord(UUIDUtils.getId(),zyOwnerVO.getOwnerRoom().getOwnerRoomId(),zyOwnerVO.getOwnerRoom().getCommunityId(),zyOwnerVO.getOwnerRoom().getBuildingId()
                ,zyOwnerVO.getOwnerRoom().getUnitId(),zyOwnerVO.getOwnerRoom().getRoomId(),zyOwnerVO.getOwnerRoom().getOwnerId(),zyOwnerVO.getOwnerType(),
                zyOwnerVO.getOwnerRoom().getRoomStatus(),zyOwnerVO.getRemark(),"",zyOwnerVO.getOwnerRoom().getOwnerId(),"admin",
                zyOwnerVO.getOwnerRoom().getCreateTime(),"",LocalDateTime.now(),"");

        zyOwnerRoomRecordService.save(zyOwnerRoomRecord);
        return ResponseResult.ok("ok");
    }

    public ResponseResult<String> getRemarkByRecordId(){
        return ResponseResult.ok("");
    }
}

